python模块之 | 您所在的位置:网站首页 › iteration of pages › python模块之 |
1 from tqdm import tqdm
2
3 for i in tqdm(range(10000)):
4 """一些操作"""
5 pass
效果: 下面说一下tqdm中的参数: iterable=None, desc=None, 传入str类型,作为进度条标题(类似于说明) total=None, 预期的迭代次数 leave=True, file=None, ncols=None, 可以自定义进度条的总长度 mininterval=0.1, 最小的更新间隔 maxinterval=10.0, 最大更新间隔miniters=None, ascii=None, unit='it',unit_scale=False, dynamic_ncols=False, smoothing=0.3,bar_format=None, initial=0, position=None, postfix 以字典形式传入 详细信息 例如 速度= 10, 1 dict = {"a":123,"b":456} 2 for i in tqdm(range(10),total=10,desc = "WSX",ncols = 100,postfix = dict,mininterval = 0.3): 3 pass结果: 1 from tqdm import trange 2 from random import random, randint 3 from time import sleep 4 with trange(100) as t: 5 for i in t: 6 # Description will be displayed on the left 7 t.set_description('下载速度 %i' % i) 8 # Postfix will be displayed on the right, 9 # formatted automatically based on argument's datatype 10 t.set_postfix(loss=random(), gen=randint(1,999), str='详细信息', 11 lst=[1, 2]) 12 sleep(0.1)类似显示一个标题和详细信息。 效果: 。。。。 |
CopyRight 2018-2019 实验室设备网 版权所有 |